#include <iostream>
#include <opencv2/opencv.hpp>

static void onMouse (int event, int x, int y, int, void *data)
{
	switch (event) {
	case CV_EVENT_LBUTTONDOWN:
		std::cout << "(" << x << ", " << y << ")" << std::endl;
		break;
		
	default:
		break;
	}
}

int main(int argc, char **argv)
{
	cv::VideoCapture capture(0);
	cv::Mat mat;

	if (!capture.isOpened()) {
		return -1;
	}

	cv::namedWindow("window");
	cv::setMouseCallback("window", onMouse, &mat);
	while (true) {
		capture >> mat;
		cv::imshow("window", mat);
		if (cv::waitKey(300) != -1) {
			break;
		}
	}
	return 0;
}
